//
//  addMemverController.m
//  soccer
//
//  Created by 上官千城 on 15/9/4.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "addMemverController.h"

@interface addMemverController ()

@end

@implementation addMemverController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"添加联系人";
    
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    [self afnGetRequest];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStyleDone target:self action:@selector(sureButton)];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonItemStyleDone target:self action:@selector(cancleButton)];
    
    //去掉底部多余的表格线
    [self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
}
//取消方法
-(void)cancleButton
{
    NSLog(@"取消");
    [self.navigationController popViewControllerAnimated:YES];
}
//确定
-(void)sureButton
{
    NSLog(@"确定");
}
//行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 30;
    }
    return 70;
}
//tableView协议方法
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0)
    {
        UITableViewCell *cell1 = [[UITableViewCell alloc]init];
        
        cell1.textLabel.text = @"选择联系人";
        return cell1;
    }
    else {
    static NSString *cellInfo = @"addMemberCell";
    addMemverCell *cell = [tableView dequeueReusableCellWithIdentifier:cellInfo];
    if (cell == nil) {
        cell = [[addMemverCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellInfo];
        
    }
        return cell;
    }
    return nil;
    
}
//允许编辑
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete|UITableViewCellEditingStyleInsert;

}
//行数

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
//点击触发方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([self.navigationItem.rightBarButtonItem.title isEqualToString:@"确定"]) {
//        [deleteDic setObject:indexPath forKey:[dataArray objectAtIndex:indexPath.row]];
        
    }
    else {
        
    }
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([self.navigationItem.rightBarButtonItem.title isEqualToString:@"确定"]) {
       
    }
    
}

-(void)afnGetRequest
{
    
      AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];
    NSString *url_string = @"";
    
    
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"application/x-javascript",@"text/html",nil];
    
    
    [manager GET:url_string parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [netWorkManager stopMonitoring];
                NSLog(@"使用AFN进行get请求 ===  %@",responseObject);
        //        [[DateHandel shareHandle]dropTable];
        //        [[DateHandel shareHandle]createTable];
        //        [self.array removeAllObjects];
       
        NSMutableArray *array = [NSMutableArray array];
        
        
        [self.tableView reloadData];
        //        [self.HUD hide:YES];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"失败==== %@",error);
        //        [self.HUD hide:YES];
     
        
    }];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
